const mongoose = require('mongoose');

mongoose.connect('mongodb://localhost/mytest',{useUnifiedTopology: true,useNewUrlParser: true})
  .then(()=> console.log('链接成功'))
  .catch(err => console.log(err,'链接失败'))

const UserSchema = new mongoose.Schema({
  name: String,
  author: String,
  email: String,
  age: Number,
  hobbise: [String]
});

const User = mongoose.model('User',UserSchema);
//查询用户集合所有的
// User.find().then(res =>{
//   console.log(res);
// })
User.find().select('age name')
  .then(res=>console.log(res))